/*package userCollenter.dao;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class UserDao {

    @Autowired
    private RestTemplate restTemplate;
*//**
 * 通过http路径访问服务
 *//*
    *//*public SecurityProperties.User queryUserById(List<String> id) {
        String url = "http://localhost:8081/user/" + id;
        return this.restTemplate.getForObject(url, SecurityProperties.User.class);
    }*//*

    *//**
     * 熔断器的工作机制
     *//*
    private static final Logger logger = LoggerFactory.getLogger(UserDao.class);

    @HystrixCommand(fallbackMethod = "queryUserById1")

    public String queryUserById(String id){
        long begin = System.currentTimeMillis();
        String url = "http://user-service/user/" + id;
        String user = this.restTemplate.getForObject(url, String.class);
        long end = System.currentTimeMillis();
        // 记录访问用时：
        logger.info("访问用时：{}", end - begin);
        return user;
    }

    public String queryUserById1(String id){
        logger.error("服务器失败");
        return "用户信息查询出现异常";
    }

}*/
